<?php 
	class Member_test extends CI_Controller{
		public function __construct(){
			parent::__construct();
		}
		
		public function login(){
			$arrs = array();

			$data = $_POST;
			
			$username 		=trim($data['username']);
			$password			=trim($data['password']);
			$customer_name = trim($data['customer_name']);
			$imie					=trim($data['imie']);

			$arrs['StatusID']  		= "0";
			$arrs['Error']				="";
			$arrs['status']			="Username=".$username.", Password=".$password.", Customer Name = ".$customer_name.", Imie=" . $imie;

			echo json_encode($arrs);
		}
		
		public function signup(){
			$arrs = array();
			$name 		= $this->input->post('name');
			$email		= $this->input->post('email');
			$mobile		= $this->input->post('mobile');
			$country    = $this->input->post('country');
			$pkid 		= $this->input->post('pkid');
			$imie 		= $this->input->post('imie');
			//$pkid 		= "1";
			$address	= $this->input->post('address');
			//check partner
			$this->db->select("customer_pkid");
			$this->db->where("pkid",$pkid);
			$row = $this->db->get("mobile_card")->row();
			
			//check country
			$this->db->select("pkid");
			$this->db->where("name",$country);
			$rowc = $this->db->get("mobile_country")->row();
				$data = array(
							"customer_pkid"=>$row->customer_pkid,
							"card_pkid"=>$pkid,
							"email"=>$email,
							"name"=>$name,
							"mobile"=>$mobile,
							"address"=>$address,
							"country"=>$rowc->pkid,
							"imei"=>$imie
						);
				$resin = $this->db->insert("mobile_member",$data);			
					if($resin){
						$arrs['StatusID']  	= "1";
						$arrs['Error']			="";
					}else {
						$arrs['StatusID']  	= "0";
						$arrs['Error']			="Register fail";
					}
					echo json_encode($arrs);
		}
		
		public function check_imie(){
			$imie = $this->input->post("imie");
			//$imie = "358867040228009";
			$this->db->where("imei",$imie);
			$num = $this->db->count_all_results("mobile_member");
			if($num == 0){
				$arrs['StatusID']  	= "1";
				$arrs['Error']			="";
			}else{
				$arrs['StatusID']  	= "0";
				$arrs['Error']			="";
			}
			echo json_encode($arrs);
		}
		
		
		
	}	
?>